package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizCouponReceive;
import com.member.shop.mapper.SysBizCouponReceiveMapper;
import com.member.shop.service.ISysBizCouponReceiveService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 优惠券用户领取记录Service业务层处理
 *
 * @author lixinchen
 * @date 2024-05-08
 */
@Service
public class SysBizCouponReceiveServiceImpl extends ServiceImpl<SysBizCouponReceiveMapper, SysBizCouponReceive> implements ISysBizCouponReceiveService {
    @Resource
    private SysBizCouponReceiveMapper sysBizCouponReceiveMapper;

    /**
     * 查询优惠券用户领取记录
     *
     * @param id 优惠券用户领取记录主键
     * @return 优惠券用户领取记录
     */
    @Override
    public SysBizCouponReceive selectSysBizCouponReceiveById(Long id) {
        return sysBizCouponReceiveMapper.selectById(id);
    }

    /**
     * 查询优惠券用户领取记录列表
     *
     * @param queryWrapper 优惠券用户领取记录
     * @return 优惠券用户领取记录
     */
    @Override
    public List<SysBizCouponReceive> selectSysBizCouponReceiveList(LambdaQueryWrapper<SysBizCouponReceive> queryWrapper) {
        return sysBizCouponReceiveMapper.selectList(queryWrapper);
    }

    /**
     * 新增优惠券用户领取记录
     *
     * @param sysBizCouponReceive 优惠券用户领取记录
     * @return 结果
     */
    @Override
    public int insertSysBizCouponReceive(SysBizCouponReceive sysBizCouponReceive) {
        sysBizCouponReceive.setCreateTime(DateUtils.getNowDate());
        return sysBizCouponReceiveMapper.insert(sysBizCouponReceive);
    }

    /**
     * 修改优惠券用户领取记录
     *
     * @param sysBizCouponReceive 优惠券用户领取记录
     * @return 结果
     */
    @Override
    public int updateSysBizCouponReceive(SysBizCouponReceive sysBizCouponReceive) {
        sysBizCouponReceive.setUpdateTime(DateUtils.getNowDate());
        return sysBizCouponReceiveMapper.updateById(sysBizCouponReceive);
    }

    /**
     * 批量删除优惠券用户领取记录
     *
     * @param ids 需要删除的优惠券用户领取记录主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCouponReceiveByIds(Long[] ids) {
        return sysBizCouponReceiveMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除优惠券用户领取记录信息
     *
     * @param id 优惠券用户领取记录主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCouponReceiveById(Long id) {
        return sysBizCouponReceiveMapper.deleteById(id);
    }

    @Override
    public List<SysBizCouponReceive> queryCouponByUser(SysBizCouponReceive sysBizCouponReceive) {
        return sysBizCouponReceiveMapper.queryCouponByUser(sysBizCouponReceive);
    }

    @Override
    public List<SysBizCouponReceive> selectSysBizCouponReceiveList(SysBizCouponReceive sysBizCouponReceive) {
        return sysBizCouponReceiveMapper.selectSysBizCouponReceiveList(sysBizCouponReceive);
    }

    @Override
    public List<SysBizCouponReceive> selectSysBizCouponReceiveByGoods(SysBizCouponReceive build) {
        return sysBizCouponReceiveMapper.selectSysBizCouponReceiveByGoods(build);
    }
}
